<template>
  <div class="auto">
    <form  class="form-horizontal">
      <p class="bg-info text-center" style="padding: 8px;">更改抄表员</p>
    <validator name='v'>
      <div class="row">
      <label for="f_inputtor" class="col-sm-2 control-label">现抄表员姓名:</label>
      <div class="col-sm-2" id="f_inputtor">
        <v-select id="f_inputtor"
        v-model="model.f_inputtor"
        placeholder='请选择'
        :value.sync="model.f_inputtor"
        :options='meterReader'
        close-on-select clear-button>
        </v-select>
      </div>
    </div>
      <div class="row" style="margin-top:10px;">
          <label for="f_change_cause" class=" col-sm-2 control-label">修改原因:</label>
          <div class="col-sm-8">
            <textarea class="form-control"   v-validate:f_reason='{required: true }'
             v-model="model.f_reason" rows="3" placeholder="请填写原因"></textarea>
        </div>
      </div>
  </validator>
   </form>
   <div style="text-align:right;height:auto;margin-top:50px;margin-right:50px;">
     <button class="btn btn-success" @click="confirm()"  :disabled='!$v.valid'>确&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;认</button>
     <button class="btn btn-default" @click="clean()" style="width:80px;margin-left:20px;">取&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;消</button>
   </div>
  </div>
</template>
<script>
import AppData from '../../../../../stores/AppData'
import * as Util from '../../../../Util'

export default {
  title: "批量操作",
  data () {
    return {
      model: {
        f_inputtor:['请选择'],
        f_reason:''
      }
    }
  },
props:['data'],

methods:{
  clean () {
    this.$info('取消操作')
    this.$dispatch('clean', '批量操作')
  },
  confirm () {
    let send = {
      data: {
        f_change_content: this.model.f_inputtor[0],
        f_change_cause: this.model.f_reason,
        condition: this.data.condition,
        f_operator: Util.f.name,
        f_change_count: this.data.count,
        f_change_type: '抄表员变更',
        f_filiale: Util.f.f_fengongsi,
        f_outlets: Util.f.f_parentname
      }
    }
    this.$LogicService.updateInputtor(send)
    .then(
      (res) => {
        this.$dispatch('success', '批量操作', this.data, res)
      }
    ).catch(
      (error) => {
        this.$dispatch('error', '批量操作', this.data, error)
      }
    )
  },

},
computed: {
  meterReader () {
    return AppData.getParam('抄表员')
  }
}
}
</script>
